/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.maxato.modellen;

import java.util.List;
import javax.swing.table.AbstractTableModel;

import nl.maxato.domain.Discipline;

/**
 *
 * @author Danny
 */
public class SpecialiteitTableModel extends AbstractTableModel {

    private List<Discipline> discipline;
    String[] columnNames = {"Discipline", "Totaal waarde"};
    //private Atleet atleet;
    //private List<Usertabel> following;

    public SpecialiteitTableModel(List<Discipline> discipline) {
        this.discipline = discipline;
        //this.atleet = atleet;
        //following = user.getUsertabelCollection();
        //System.out.println("Following: " + atleet.getUsertabelCollection());
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    public void setColumnNames(String discipline, String totaalWaarde) {
        String[] columnNamesNieuw = {discipline, totaalWaarde};
        this.columnNames = columnNamesNieuw;
    }

    @Override
    public String getColumnName(int col) {
        return columnNames[col];
    }

    @Override
    public int getRowCount() {
        return discipline.size();
    }

    @Override
    public Object getValueAt(int row, int col) {
        switch (col) {
            case 0:
                return discipline.get(row).getTypeOfDisciplineString();
            case 1:
                return discipline.get(row).getTotalValueDiscipline();
            default:
                throw new RuntimeException("no such column");
        }
    }

    // This method is used by the JTable to define the default
    // renderer or editor for each cell. For example if you have
    // a boolean data it will be rendered as a check box. A
    // number value is right aligned.
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return discipline.get(0).getTypeOfDisciplineString().getClass();
            case 1:
                return Integer.class;
            default:
                throw new RuntimeException("no such column");
        }
    }
}
